//封装所有用户相关的接口函数

import request from '@/utils/request'

export const userRegisterService = ({username,password,rePassword}) =>{
    return request({
        url: '/user/register',
        method: 'POST',
        data: {
            username,
            password,
            rePassword
        }
    })
}

export const userLoginService = ({username,password}) => {
    return request({
        url: '/user/login',
        method: 'POST',
        data: {
            username,
            password
        }
    })
}

export const userUpdateService = (data) => {
    return request({
        url: '/user/update',
        method: 'PUT',
        data
    })
}

export const userUpdatePwdService = ({old_pwd,new_pwd,re_pwd}) => {
    return request({
        url: '/user/updatePwd',
        method: 'PATCH',
        data: {
            old_pwd,
            new_pwd,
            re_pwd
        }
    })
}

export const userAvatarUpdateService=(avatarUrl)=>{
    return request({
        url: `/user/updateAvatar?avatarUrl=${encodeURIComponent(avatarUrl)}`,
        method: 'PATCH'
    })
}

export const getUserListService = (params) =>{
    return request({
        url: '/user/list',
        method: 'GET',
        params
    })
}

export const updateUserStatusService = (data) =>{
    return request({
        url: '/user/status/update',
        method: 'PUT',
        data
    })
}
